<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>排片</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<body>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="add()">
    <i class="layui-icon">&#xe61f;</i>添加
</button>
<table class="layui-hide" id="test"></table>
<!-- 弹出层中的表单模板 -->
<form id="roleEditForm" class="layui-form" action="playInsert" method="post" style="display:none;padding-top:10px;">
    <div class="layui-form-item">
        <label class="layui-form-label">电影</label>
        <div class="layui-input-block" style="width: 190px;">
            <select name="filmid" lay-verify="required">
                <option value=""></option>
                <c:forEach items="${filmMap}" var="item" >
                    <option value="${item.key}">${ item.value}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">场次时间</label>
            <div class="layui-input-inline">
                <input type="datetime-local" class="layui-input" name="time" placeholder="yyyy-MM-dd HH:mm:ss">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">语言</label>
        <div class="layui-input-inline">
            <input type="text" name="lantype" id="lantype" required lay-verify="required" placeholder="请输入"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">放映厅</label>
        <div class="layui-input-block" style="width: 190px;">
            <select name="roomid" lay-verify="required">
                <option value=""></option>
                <c:forEach items="${roomMap}" var="item" >
                    <option value="${item.key}">${ item.value}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">票价</label>
        <div class="layui-input-inline">
            <input type="text" name="price" id="price" required lay-verify="required" placeholder="请输入"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="closeEditWin()">取消</button>
        </div>
    </div>

</form>

<script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#test',
            url: 'playAll',
            // cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            //     ,
            cols: [
                [{
                    field: 'p_id',
                    align: 'center',
                    title: 'ID',
                    sort: true
                }, {
                    field: 'f_name',
                    align: 'center',
                    title: '电影'
                }, {
                    field: 'p_time',
                    align: 'center',
                    title: '场次'
                }, {
                    field: 'lan_type',
                    align: 'center',
                    title: '语言'
                }, {
                    field: 'price',
                    align: 'center',
                    title: '票价'
                }, {
                    field: 'room_name',
                    align: 'center',
                    title: '放映厅'
                }, {
                    field: 'setup',
                    align: 'center',
                    title: '设置'
                }]

            ],
            page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
            },
            limit: 5,
            limits: [1, 2, 3, 4, 5]
        });
    });

    function add() {
        var obj = {
            "action": "playInsert",
            "tit": "添加排片"
        }
        popupwin(obj);
    }

    function popupwin(obj) {
        layui.use(['layer'], function () {
            var layer = layui.layer;
            var $ = layui.jquery;
            $('#roleEditForm').attr('action', obj.action);
            layer.open({
                type: 1, //5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                area: [500], //宽高
                title: obj.tit,
                content: $('#roleEditForm')
            });
        });
    }

    function closeEditWin() {
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.closeAll();
        });
    }
    layui.use('layer', function () {
        var layer = layui.layer;
        ${msg}
    });
</script>

</body>

</html>
